package com.xujl.mvcbind.ui.custom.model;

import android.graphics.Color;
import android.widget.ImageView;
import android.widget.TextView;

import com.xujl.fastlib.base.BaseModel;
import com.xujl.fastlib.base.IControl;
import com.xujl.fastlib.utils.ImgHelper;
import com.xujl.mvcbind.bean.CustomBean;

import androidx.databinding.BindingAdapter;


/**
 * <pre>
 *     author : xujl
 *     e-mail : 597355068@qq.com
 *     time   : 2019/08/20
 *     desc   :
 *     version: 1.0
 * </pre>
 */

public class CustomAttrFragmentModel extends BaseModel {
    @Override
    public void init (IControl control) {

    }

    @BindingAdapter("urlImage")
    public static void urlImage (ImageView imageView, String url) {
        ImgHelper.loadImgNormal(imageView.getContext(), imageView, url);
    }

    @BindingAdapter("urlCircleImage")
    public static void urlCircleImage (ImageView imageView, String url) {
        ImgHelper.loadCircleImg(imageView.getContext(), imageView, url);
    }

    @BindingAdapter("stateChange")
    public static void stateChange (TextView textView, int state) {
        switch (state) {
            case 0:
                textView.setText("状态1");
                textView.setTextColor(Color.YELLOW);
                break;
            case 1:
                textView.setText("状态2");
                textView.setTextColor(Color.RED);
                break;
            case 2:
                textView.setText("状态3");
                textView.setTextColor(Color.GREEN);
                break;
            default:

                break;

        }
    }

    public CustomBean getCustomBean () {
        CustomBean customBean = new CustomBean();
        customBean.setImageUrl("https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2188597425,2340077467&fm=11&gp=0.jpg");
        customBean.setState1(0);
        customBean.setState2(1);
        customBean.setState3(2);
        return customBean;
    }
}
